package howl.types;


import java.io.IOException;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.users.User;
import compiler.HowlType;
import compiler.terminals.expression.Node;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Alarm {
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	
	@Persistent
	private User owner;
	
	@Persistent
	private String Feedname;
	
	@Persistent
	private byte[] exp;
	
	public Alarm(Node exp) throws IOException {
		super();
		this.exp = Serializer.put(exp);
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public User getOwner() {
		return owner;
	}

	public void setOwner(User owner) {
		this.owner = owner;
	}


	/**
	 * @return the feedname
	 */
	public String getFeedname() {
		return Feedname;
	}

	/**
	 * @param feedname the feedname to set
	 */
	public void setFeedname(String feedname) {
		Feedname = feedname;
	}

	/**
	 * @return the exp
	 */
	public Node getExp() {
		try {
			return (Node) Serializer.get(this.exp);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * @param exp the exp to set
	 */
	public void setExp(byte[] exp) {
		this.exp = exp;
	}

}

